package com.xizimall.service.impl;

import java.util.Date;
import java.util.List;

import org.omg.CORBA.DATA_CONVERSION;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mysql.fabric.xmlrpc.base.Data;
import com.xizimall.mapper.TbItemParamMapper;
import com.xizimall.pojo.TbItemParam;
import com.xizimall.pojo.TbItemParamExample;
import com.xizimall.pojo.TbItemParamExample.Criteria;
import com.xizimall.service.ItemParamService;
import com.xizimall.common.pojo.XizimallResult;
/**
 * 商品规格模板
 * <p>Title: ItemParamServiceImpl</p>
 * <p>Description: </p>
 * <p>华南理工大学研究生</p> 
 * @author	李隆熹
 * @date	2018年4月16日下午8:20:56
 * @version 1.0
 */
@Service
public class ItemParamServiceImpl implements ItemParamService {
    @Autowired
    TbItemParamMapper itemParamMapper;
	@Override
	public XizimallResult getItemParamByCid(long cid) {
		TbItemParamExample example=new TbItemParamExample();
		 Criteria criteria=example.createCriteria();
		criteria.andItemCatIdEqualTo(cid);
		List<TbItemParam> list =itemParamMapper.selectByExampleWithBLOBs(example);
		//判断结果是否查询到
		if(list!=null && list.size()>0){
			return XizimallResult.ok(list.get(0));
		}
		return XizimallResult.ok();
	}
	@Override
	public XizimallResult insertItemParam(TbItemParam itemParam) {
		//补全pojo
		itemParam.setCreated(new Date());
		itemParam.setUpdated(new Date());
		itemParamMapper.insert(itemParam);
		return XizimallResult.ok();
	}

}
